// Filename: views/projects/list
define([
    'jquery',
    'underscore',
    'backbone'
], function($, _, Backbone) {
    var ListView = Backbone.View.extend({
        el: $("#main-list"),
        events: {"click #delete": "delete"},
        render: function() {
            var data = {
                list: this.collection.models,
                _: _
            };
            var compiledTemplate = _.template(this.options.list, data);
            $("#main-list").html(compiledTemplate);
            var len = 10 - parseInt($('.table >tbody >tr').length);
            for (var i = 0; i < len; i++) {
                $('.table >tbody').append("<tr><td colspan=13  style=\"height: 22px;\">&nbsp;</td></tr>");
            }
            $("#main-pagination").html('<ul />');
            var len = this.options.count;
            var pageCount = Math.ceil(len / 10);
            for (var i = 0; i < pageCount; i++) {
                if (this.options.pag == i + 1) {
                    $('ul', $("#main-pagination")).append("<li class=\"active\"><span><b>" + (i + 1) + "</b></span></li>");
                } else {
                    $('ul', $("#main-pagination")).append("<li class=\"disabled\"><span style=\"cursor: pointer;\" id=\"pag\" index=\"" + (i + 1) + "\" >" + (i + 1) + "</span></li>");
                }
            }
        },
        delete: function() {

        }
    });
    return ListView;
});
